package com.query;

import org.apache.commons.lang3.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

public class ManagerQueryLink extends BaseQueryComplex {

    private String searchKey;
    private String searchValue;
    private Date minCreated;
    private Date maxCreated;
    private Integer disabled;
    private Long departmentId;

    @Override
    protected void init() {
        if (StringUtils.isNotBlank(searchValue)) {
            if ("0".equals(searchKey)) {
                params.put("name", "%" + StringUtils.trim(searchValue) + "%");
            } else if ("1".equals(searchKey)) {
                params.put("mobile", "%" + StringUtils.trim(searchValue) + "%");
            }
        }
        if (null != minCreated) {
            params.put("minCreated", minCreated);
        }
        if (null != maxCreated) {
            params.put("maxCreated", maxCreated);
        }
        /*if (null == disabled) {
            disabled = 0;
        }
        params.put("disabled", disabled);*/
        if (null != disabled) {
            params.put("disabled", disabled);
        }

        if (null != departmentId) {
            params.put("departmentId", departmentId);
        }
    }

    @Override
    public String sortOrder() {
        return "T0.created DESC";
    }

    public String getSearchKey() {
        return searchKey;
    }

    public void setSearchKey(String searchKey) {
        this.searchKey = searchKey;
    }

    public String getSearchValue() {
        return searchValue;
    }

    public void setSearchValue(String searchValue) {
        this.searchValue = searchValue;
    }

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    public Date getMinCreated() {
        return minCreated;
    }

    public void setMinCreated(Date minCreated) {
        this.minCreated = minCreated;
    }

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    public Date getMaxCreated() {
        return maxCreated;
    }

    public void setMaxCreated(Date maxCreated) {
        this.maxCreated = maxCreated;
    }

    public Integer getDisabled() {
        return disabled;
    }

    public void setDisabled(Integer disabled) {
        this.disabled = disabled;
    }

    public Long getDepartmentId() {
        return departmentId;
    }

    public void setDepartmentId(Long departmentId) {
        this.departmentId = departmentId;
    }
}